<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 可以在组件的标签中间写内容，这个内容会去替换子组件的slot标签 -->
      <!-- 作用: 内容分发 -->

      <!-- 插槽也是父传子的一种方式 -->
      <!-- 插槽不仅能传js数据类型，还能传标签, 传组件 -->
      <h2>插槽</h2>
      <child>{{ str }}</child>
      <child><span>world</span></child>
      <child><child2></child2></child>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      const Child2 = {
        template: "<span>child2组件</span>",
      };

      const Child = {
        // template选项，相当于document.querySelector("child").outerHTML = template
        template: `
          <div>child组件 - <slot></slot></div>
        `,
      };

      createApp({
        data() {
          return {
            str: "hello",
          };
        },
        components: {
          Child,
          Child2,
        },
      }).mount("#app");
    </script>
  </body>
</html>
